﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using WmsApp.WmsService;

namespace WmsApp.Service
{
    public class InStoreBillWrapService : IWrapService<InStoreBillWrap>
    {

        #region IWrapService<InStoreBillWrap> Members

        public void SaveWrap(InStoreBillWrap wrap)
        {
            var sc = Factory.WmsServiceFactory.GetServiceClient();
            sc.SaveInStoreBillWrap(wrap);
            wrap.PInStoreBill.WcfEntityState = EntityState.Unchanged;
            if (wrap.PInStoreBillDtl != null && wrap.PInStoreBillDtl.Count > 0)
            {
                foreach (var c in wrap.PInStoreBillDtl)
                {
                    c.WcfEntityState = EntityState.Unchanged;
                }
            }
        }

        public InStoreBillWrap GetWrap(string wrapMasterID)
        {
            var sc = Factory.WmsServiceFactory.GetServiceClient();
            var wrap = sc.GetInStoreBillWrap(wrapMasterID);
            wrap.PInStoreBill.WcfEntityState = EntityState.Unchanged;
            wrap.PInStoreBill.BindPropertyChanged();
            if (wrap.PInStoreBillDtl != null && wrap.PInStoreBillDtl.Count > 0)
            {
                foreach (var c in wrap.PInStoreBillDtl)
                {
                    c.WcfEntityState = EntityState.Unchanged;
                    c.BindPropertyChanged();
                }
            }
            return wrap;
        }

        #endregion
    }
}
